import React from 'react';
import {inject, observer} from 'mobx-react';
import { toJS } from 'mobx';
import { withRouter ,Route } from 'react-router-dom';
import { Base64 } from 'js-base64';
import classnames from 'classnames';
import { Bubble,Button, Tools, Modal, Toast, Icon } from 'weaver-mobile';
import { Reply,RouteLayout,CKRichText, MapPage  } from 'weaver-mobile-page';
import WeaUtils from '../../public/wea-utils';
import DiscussShareTool from "./DiscussShareTool";


const getLabel = Tools.getLabel;
const getCurrentPosition = MapPage.getCurrentPosition;
const alert = Modal.alert;
const Card = require('../../../ecme/components/card').default;
const OthersStore = require('../../../ecme/stores/card/cardStore').default;
const NoMask = Reply.NoMask;
const ButtonGroup = RouteLayout.ButtonGroup;


@withRouter
@inject('blogCommentStore')
@observer
export default class BlogWrite extends React.Component {
  static defaultProps = {
    prefixCls: 'blog-comment-write'
  }
  constructor(props) {
    super(props);
    this.state = {
      locationading:false,
      noteLoading:false,
      positionLoading: false,
      position: '',
      address: '',
      positionError: false,
      test:'',
      intervalRichContent:'',
        isInit:false,
        layoutParam: {},
        templateType:'0',
        shareType:1,
        shareValue:[],
        isButton:false,
        shareUserList:[],
        partid:0,
        templateId:"0",
        bdShare:"0"
    }
  }


    changeShareUserList = (ss) =>{
        this.setState({shareUserList:ss})
    }


    /**
     * 保存方法 先校验必填  返回是否通过、表单内容及相关参数
     */
    handleSubmit = (type) => {
        const { handleSubmit } = this.state.cardStore;
        const {saveBlogEcmeInfo,updateBlogEcmeinfo,saveBlogNoteEcmeinfo,ecmeReply,writeReply} = this.props.blogCommentStore;
        const {templateType,position,shareType,shareValue,address,partid} = this.state;
        let a = handleSubmit();


        let ecmeExtend = {};

        let moodd = '1';
        const { history, match } = this.props;
        if(toJS(ecmeReply.attachList)[0]&&toJS(ecmeReply.attachList)[0].key=="mood"){

            if(toJS(ecmeReply.attachList)[0].iconType=='blog-biaoqing'){
                moodd='1'
            }else{
                moodd='2'
            }

        }

        const saveParams = position && {
            locationX: position[0],
            locationY: position[1],
            locationName: address,
        }
        const store = this.getStore();
        const { discussId, workdate,replyComment} = store;
        const writeBlogDate = WeaUtils.DateFormat(new Date(), 'yyyy-MM-dd');
        ecmeExtend= a.JSONStr.extendDatas;
        let params = {
            ecmeExtend: JSON.stringify(ecmeExtend),
            appItemId:  moodd,
            comefrom: 4,
            content: partid==0?writeReply.getData().richText:"",
            shareType:shareType,
            shareValue:shareValue.join(','),
            partid:partid,
            workdate: match.path.indexOf('writeBlog') === -1 ? workdate : writeBlogDate,
            ...saveParams
        }



        if(window.location.href.indexOf('/myBlog/writeBlog')>0||discussId==null){

            if(type=='note'){
                saveBlogNoteEcmeinfo(
                    params,
                    result => {
                        Toast.hide();
                        Toast.success('保存成功' , 1);
                        replyComment ? history.go(-1) : history.push('/myBlog/blog')
                    }
                )
            }else{
                saveBlogEcmeInfo(params,(res) => {
                    Toast.hide();
                    Toast.success(getLabel(513696,'发布成功!') , 1);
                    replyComment ? history.go(-1) : history.push('/myBlog/blog')
                })
            }



        }else{
            params.blogId=discussId;
            updateBlogEcmeinfo(params,(res) => {

                store.blogCommentStore.doOperateReply({
                    replyId: this.replyComment ? this.replyComment.replyId : res.replyList[0].replyId,
                    reply: res.replyList[0],
                })

                Toast.hide();
                Toast.success(getLabel(513696,'发布成功!') , 1);
                replyComment ? history.go(-1) : history.push('/myBlog/blog');
            })
        }


    }

    /**
     * 字段变更回调
     */
    onFieldChange = (a, b) => {

        if(a.formItemType=='RICHTEXT'){
            const store = this.getStore();
            const {  setBlogText} = store;
            setBlogText(b);
        }

    }

  componentWillMount() {
    const {blogCommentStore} = this.props;
    blogCommentStore.setRoutePath(this.props.location.pathname);
    blogCommentStore.setReplyConfig();
  }


  changeEmojField = (val) => {
      const {changeField} = this.state.cardStore;
     let fieldKey = Object.keys(this.state.cardStore.form.ckTextareas);
      let kye = this.state.cardStore.form.ckTextareas[fieldKey[0]].id;
      let content = this.state.cardStore.form.ckTextareas[fieldKey[0]].text;
      content = content.replace(new RegExp('<p>','g'),'');
      content = content.replace(/(.*)<\/p>/,'$1')
      changeField({[kye]:{value:content+val}})
  }

  changeImgField = (val) => {
      const {changeField} = this.state.cardStore;
      let content = this.state.cardStore.form.ckTextareas[fieldKey[0]].text;
      let fieldKey = Object.keys(this.state.cardStore.form.ckTextareas);
      let kye = this.state.cardStore.form.ckTextareas[fieldKey[0]].id;
      let a = `<img data-cke-saved-src=${val[0].url} src=${val[0].url} className='richTextImgInnerTemp'/>`;
      content = content.replace(new RegExp('<p>','g'),'');
      content = content.replace(/(.*)<\/p>/,'$1')
      content = content+a;
      changeField({[kye]:{value:content+val}})
  }

  componentDidMount() {

      const { blogCommentStore: { writeReply,discussShareInfo,attentionUserList } } = this.props;
      const store = this.getStore();

      const { getDefaultTemplate,getEcmeTemplate,getBlogNoteEcmeinfo, getBlogEcmeInfo,discussId,blogText,partid,workdate, type, setBlogText,userid,getBlogNote,getBlogByUserDate,isBlogNote,routePath,getTimerByNote} = store;



      let templateType = '0';
      getTimerByNote({},(_param) => {
        if(_param.notetiming=="1"){

          this.timer = setInterval(
            () => {
              this.saveNoteByInterval(true);
            },
            _param.notetime
          );
        }
      })


   if(this.props.location&&this.props.location.state){
       templateType = this.props.location.state.templateType;
   }

      let bdShare = "0";
      if(this.props.location&&this.props.location.state){
          bdShare = this.props.location.state.bdShare;
      }



        if(!type){
            if(window.location.href.indexOf('/myBlog/writeBlog')>0){
                attentionUserList({discussid:0,pageIndex:1},(res) => {
                    this.setState({shareType:res.shareType,shareUserList:res.list,shareValue:res.shareValue,bdShare:bdShare})
                })
                if(templateType=='1'){
                    getBlogNoteEcmeinfo({},res => {
                        let cardStore = new OthersStore();
                        res.data.rute = "/myBlog/writeBlog";
                        if(res.data.billid.indexOf('note')>-1){
                            setBlogText('&nbsp')
                        }

                        this.setState({ cardStore: cardStore, isInit: true, layoutParam: res.data,templateType:templateType,partid:res.partid })

                    });
                }else{
                    getBlogNote({workdate: WeaUtils.DateFormat(new Date(), 'yyyy-MM-dd')},(_param) => {
                        writeReply.setData({richText: _param});
                        this.setState({intervalRichContent:_param})
                        setBlogText(_param);
                    })
                }
            } else{
                getDefaultTemplate({workdate: WeaUtils.DateFormat(new Date(), 'yyyy-MM-dd')},(_param) => {

                    writeReply.setData({richText: _param});
                    this.setState({intervalRichContent:_param})
                    setBlogText(_param);
                });
            }
    }else if(type === '3'){
            //补交



            getEcmeTemplate({workdate: workdate},(_param) => {

                if(_param.data&&_param.data.isecme&&_param.data.isecme=='1'){
                    let cardStore = new OthersStore();
                    _param.data.rute = "/myBlog/blog/writeMyBlog";
                    this.setState({ cardStore: cardStore, isInit: true, layoutParam: _param.data,templateType:"1",partid:_param.partid })
                }else{
                    writeReply.setData({richText: _param});
                    this.setState({intervalRichContent:_param})
                    setBlogText(_param);
                }


            });

            attentionUserList({discussid:0,pageIndex:1},(res) => {
                this.setState({shareType:res.shareType,shareUserList:res.list,bdShare:res.bdShare,shareValue:res.shareValue})
            })


    }else{

            attentionUserList({discussid:discussId,pageIndex:1},(res) => {
                this.setState({shareType:res.shareType,shareUserList:res.list,bdShare:res.bdShare,shareValue:res.shareValue})
            })

            if(partid>0){
                 getBlogEcmeInfo({blogid:discussId,partid:partid},res => {
                     let cardStore = new OthersStore();
                     res.data.rute = "/myBlog/blog/writeMyBlog";
                     this.setState({ cardStore: cardStore, isInit: true, layoutParam: res.data,templateType:"1",partid:partid })
                 });

          }else{
              writeReply.setData({richText: blogText})
          }

      }
  }

    componentDidUpdate(prevProps, prevState) {
        const { blogCommentStore: {routePath } } = this.props;
        if(routePath==='/myBlog/writeBlogNote'){
            this.props.history.push('/myBlog/writeBlogNote');
        }
        this.setTitle();
    }

    setTitle = () => {
      let title = getLabel(510107,'写微博')
      if (window.em && (typeof window.em.checkJsApi === 'function') && window.em.checkJsApi('changeTitle')) {
        window.em.changeTitle({ title });
      }
      window.document.title = title;
    }

    componentWillUnmount() {
    const store = this.getStore();
    if(store.notetiming=="1"){
      this.timer && clearInterval(this.timer);
    }
    store.clearBlogText();
  }



  getStore = () => {
    const {writeBlogStore, storeName} = this.props;
    return writeBlogStore[storeName] || writeBlogStore;
  }

  onBrowserChange = (key, datas) => {
    const { blogCommentStore: { writeReply,getEcmeTemplate } } = this.props;
    datas.map(v => {
      if(key === 'template'){
        const store = this.getStore();
        const { blogText} = store;

          Modal.alert(getLabel(505615,'替换当前内容？'),'', [
            { text: getLabel(31129, '取消') },
            {
              text: getLabel(33703, '确认'),
              onPress: () => {
                   let parr = v.id.split("_");
                   if(parr[1]=='1'){
                       getEcmeTemplate({templateId:parr[0]},(res) => {
                           let cardStore = new OthersStore();
                           res.data.rute = "/myBlog/writeBlog";

                           this.setState({ cardStore: cardStore,templateType:"1",layoutParam: res.data,isInit: true})
                       });
                   }else{
                       this.setState({templateType:parr[1]});
                   }
                   writeReply.setData({richText: `${v.name}`});
              }
            },
          ])
      }else{
        writeReply.insertHtml(`<a href="javascript:void(0)" style="text-decoration:underline !important;" linkid="${v.id}" linktype="${key}" onclick="try{return openAppLink(this,${v.id});}catch(e){}">${v.name}</a>&nbsp;&nbsp;&nbsp;`);
      }
    });
  }

	//附件上传后事件
  onUploadChange = (key, datas) => {
		const { blogCommentStore: { writeReply } } = this.props;
		let str="";
		datas.map(item => {
            str = `<a href='javascript:void(0)' onclick='try{opendoc1(${item.fileid},this);return false;}catch(e){}' ondblclick='return false;' unselectable='off' contenteditable='false' style='cursor:pointer;text-decoration:underline !important;margin-right:8px'>${item.filename}</a>
            &nbsp;<a href='javascript:void(0)'  onclick='try{downloads(${item.imagefileid},this,"${item.filename}");return false;}catch(e){}' unselectable='off' target='_blank' contenteditable='false' style='cursor:pointer;text-decoration:underline !important;margin-right:8px'>下载(${item.filesize})</a></br>`;
            writeReply.insertHtml(str);
		});
  }




    onAtChange = (datas) => {
        const { blogCommentStore: { writeReply } } = this.props;

        datas.map(v => {
            writeReply.insertHtml(`<span style="font-family:'Microsoft YaHei';font-size:12px"><span><a  uuuid="uuuid${v.id}uu" data-cke-saved-href="/hrm/HrmTab.jsp?_fromURL=HrmResource&id=${v.id}"  onclick="if(window.openLink){window.openLink.openHrm(${v.id});return false;}"  contenteditable="false"  style="cursor:pointer;text-decoration:none !important;margin-right:8px;color:#2777c1!important;"  target="_blank">@${v.lastname}</a></span>&nbsp;</span>`)
        });
    }


    publishWeiboPermission =()=>{
            const { blogCommentStore: { getIsOneSubmitInfo,setIsNoTip } } = this.props;
            let _this = this;
            getIsOneSubmitInfo(result => {
                if (result.oneSubmit == "1" && result.submitCount>0) {
                    Bubble.warning(getLabel(521404,'您已发布过今天的微博，不能再发布，已为您保存草稿。'), 3);
                        this.saveNote();
                }else{
                    if(result.oneSubmit == "1"&& result.submitCount==0){
                        alert('',getLabel('521430',"当日微博仅能提交一次，确定要发布吗？"), [
                            { text: getLabel('31129','取消') , onPress: () => console.log('cancel') },
                            { text: getLabel('826','确定') , onPress: () => {
                                        _this.blogSubmit()
                               } },
                        ])
                    }else{
                            _this.blogSubmit()
                    }
                }
            })
   }

  // 提交微博
  blogSubmit = () => {
    const { blogCommentStore: { writeReply,partid,updateBlogEcmeinfo } } = this.props;
    const { position, address,templateType,shareType,shareValue } = this.state;
      const store = this.getStore();

    if(templateType=="1"){
        this.handleSubmit();
        return;
    }

    let richContent = writeReply.getData().richText;

      let moodd = '1';

      if(toJS(writeReply.replyStore.attachList)[0]&&toJS(writeReply.replyStore.attachList)[0].key=="mood"){

          if(toJS(writeReply.replyStore.attachList)[0].iconType=='blog-biaoqing'){
              moodd='1'
          }else{
              moodd='2'
          }

      }


    if(!richContent){
        Bubble.error("请输入内容!!!");
      return;
    }

    const { history, match } = this.props;

    const { saveOrUpdateBlog, blogText,discussId, replyComment,workdate,isBlogNote,type} = store;
    const writeBlogDate = WeaUtils.DateFormat(new Date(), 'yyyy-MM-dd');
    this.setState({loading: true});
      Toast.loading(getLabel(513819,'微博发布中...') , 30);
    const saveParams = position && {
      locationX: position[0],
      locationY: position[1],
      locationName: address,
    }

    if(window.location.href.indexOf('/myBlog/writeBlog')>0||discussId==null||type==3){
        saveOrUpdateBlog({
            content: richContent,
            workdate: match.path.indexOf('writeBlog') === -1 ? workdate : writeBlogDate,
            comefrom: 4,
            shareType:shareType,
            shareValue:shareValue.join(','),
            appItemId:moodd,
            ...saveParams
        }, () => {
            Toast.hide();
            Toast.success(getLabel(513696,'发布成功!') , 1);
            replyComment ? history.go(-1) : history.push('/myBlog/blog')
        })
    }else {






        if(discussId.indexOf('_')>-1){

            updateBlogEcmeinfo(
                {blogId:discussId,
                content:richContent,partid:0,
                shareType:shareType,
                shareValue:shareValue.join(',')},(res) => {
                store.blogCommentStore.doOperateReply({
                    replyId: this.replyComment ? this.replyComment.replyId : res.replyList[0].replyId,
                    reply: res.replyList[0],
                })

                Toast.hide();
                Toast.success(getLabel(513696,'发布成功!') , 1);
                history.push('/myBlog/blog')
            })
        }else {
            saveOrUpdateBlog({
                content: richContent,
                workdate: match.path.indexOf('writeBlog') === -1 ? workdate : writeBlogDate,
                comefrom: 4,
                islate:"1",
                discussId:discussId,
                shareType:shareType,
                shareValue:shareValue.join(','),
                appItemId:moodd,
                ...saveParams
            }, () => {
                Toast.hide();
                Toast.success(getLabel(513696,'发布成功!') , 1);
                replyComment ? history.go(-1) : history.push('/myBlog/blog')
            })
        }

    }

  }


  saveNoteByInterval = () => {
    const { blogCommentStore: { writeReply } } = this.props;
    let richContent = writeReply.getData().richText;
    if(!richContent){
        return;
    }
    const writeBlogDate = WeaUtils.DateFormat(new Date(), 'yyyy-MM-dd');
    const { history,match } = this.props;
    const store = this.getStore();
    const { saveOrUpdateBlogNote, replyComment,workdate} = store;
    saveOrUpdateBlogNote({
        workdate:(match.path.indexOf('writeBlog') === -1 ? workdate : writeBlogDate),
        content: richContent,
        oldContent:this.state.intervalRichContent,
        isInterval:"1"
    }, (res) => {
         if(res.update=='1'){
          Toast.success(getLabel(520729,'草稿自动保存成功！') , 1);
          this.setState({intervalRichContent: Base64.decode(res.content)});
         }
    })
  }
    // 保存便签
    saveNote = () => {
        const { templateType } = this.state;
        if(templateType=="1"){
            this.handleSubmit('note');
            return;
        }

        const { blogCommentStore: { writeReply,isNoTip } } = this.props;
        let richContent = writeReply.getData().richText;



        if(!richContent){
            return;
        }
        const writeBlogDate = WeaUtils.DateFormat(new Date(), 'yyyy-MM-dd');
        const { history,match } = this.props;
        const store = this.getStore();
        const { saveOrUpdateBlogNote, replyComment,workdate} = store;
        this.setState({noteLoading: true});
        Toast.loading(getLabel(513820,'草稿保存中...') , 30);
        saveOrUpdateBlogNote({
            workdate:(match.path.indexOf('writeBlog') === -1 ? workdate : writeBlogDate),
            content: richContent,
        }, () => {
            Toast.hide();
            Toast.success(getLabel(513813,'草稿保存成功！') , 1);
            history.goBack();
        })


    }



    getLocaiton = () => {
    this.setState({ positionLoading: true });
    getCurrentPosition().then((result) => {
      this.setState({ positionLoading: false, position: result.position, address: result.address });
      if (!result.position) {
        this.setState({positionError: true})
      }
    });
  }


  onBrownserchange = (p1,p2) => {

        let p = p2;



      Modal.alert(getLabel(505615,'替换当前内容？'),'', [
          { text: getLabel(31129, '取消') },
          {
              text: getLabel(33703, '确认'),
              onPress: () => {
                  const { blogCommentStore: { writeReply, ecmeReply,getEcmeTemplate} } = this.props;
                  if(p2.length==0){
                      this.setState({templateType:"0"})
                      ecmeReply.activeKey = '';
                      writeReply.setData({richText: ""});
                  }else{
                      let parr = p[0].id.split("_");
                      if(parr[1]=="1"){
                          ecmeReply.activeKey = '';
                          getEcmeTemplate({templateId:parr[0]},(res) => {
                              this.setState({templateType:"1",layoutParam: res.data,isInit: true})
                          });
                      }else{
                          this.setState({templateType:"0"})
                          ecmeReply.activeKey = '';
                          writeReply.setData({richText: p[0].name});
                      }
                  }

              }
          },
      ])

  }


  // openHrm = () => {
  //       this.props.his
  // }

  onCheckOk = (p1,p2,p3) => {
   this.setState({shareType:p1,shareValue:p2,shareUserList:p3})
  }



  openShareTool = () => {
      this.setState({  isButton: false });

      const { history,blogCommentStore: { disscussShareLayoutTwo,disscussShareLayout}, prefixCls } = this.props;
      if(window.location.href.indexOf('/myBlog/writeBlog')>0){
          history.push(disscussShareLayout.path)
      }else{
          history.push(disscussShareLayoutTwo.path)
      }


  }

  render() {
    const { history,blogCommentStore: { writeReply,routePath,ecmeReply,disscussShareLayout,disscussShareLayoutTwo,cusHrmLayoutt }, prefixCls } = this.props;

    const store = this.getStore();
    const { blogText, setBlogText,discussId } =store;
    const { loading,noteLoading, position, address, positionLoading, positionError,templateType,shareType,shareValue,isButton,shareUserList } = this.state;
    const replyProps = {
        onBrowserChange: this.onBrowserChange,
        onUploadChange: this.onUploadChange,
    onAtChange:this.onAtChange,
        leftConfig: [
            {type: 'voice'},
            {type: 'blog-biaoqing'},
            {type: 'blog-tupian', model: 2},
          {type: '@'},
            {type: 'tianjia'}
        ]
    }
    const config = {
      browserContextMenuOnCtrl: false,
      enableContextMenu: false,
    }

      let isInit = this.state.isInit;

      let leftConfig = [
          {type: 'voice'},
          {type: 'blog-biaoqing'},
          {type: 'blog-tupian', model: 2},
          {type: 'tianjia'}
      ]
    const positionStr = position ? address : getLabel(22981,'位置');
    const positionName = classnames(`${prefixCls}-container-position-name`,
    {'active': address !== ''})


         let showRichDiv = {"display":"block"};
         let showEcmeDiv = {"display":"none",backgroundColor: '#fcfcfc', height: '100%'};
         if(templateType=='1'){
             showRichDiv = {"display":"none"}
             showEcmeDiv = {"display":"block",backgroundColor: '#fcfcfc', height: '100%',"overflow": "auto"};
         }

         let shareNameSt = {"padding":"8px 16px","width":"40px"};
         if(shareType==3||shareType==4){
             shareNameSt = {"padding":"8px 3px","width":"48px"};
         }



         let shareName = getLabel(2161,'公开');
         if(shareType==2){
             shareName = getLabel(83281,'私密');
         }else if(shareType==3){
             shareName = getLabel(521692,'谁可以看');
         }else if(shareType==4){
             shareName =getLabel(525176,'不给谁看')
         }


      const btns = [
          {
              key: 'submit',
              text: '确定',
              onClick: (val) => {
                  this.props.history.go(-1);
              },
              type: 'primary'
          }
      ];
    return (
      <div className={prefixCls} >
          <div  id='writeTitle'  iswrite="write" ></div>
        <div className={`${prefixCls}-container`} style={{"margin-top":"5px"}}>
                    <div className='govern-home' onClick={() => {ecmeReply.activeKey = ''}} style={showEcmeDiv}>
                        {this.state.isInit&&<Card onFieldChange={this.onFieldChange} cardStore={this.state.cardStore} {...this.state.layoutParam} />}

                    </div>
                    <div style={showRichDiv}>
                    <CKRichText store={writeReply}
                                onChange={(val) => setBlogText(val)}
                                replyProps={replyProps}
                                config={config}
                    />
                    </div>
            { templateType == '1'&&
                <NoMask
                store={ecmeReply}
                showInput={false}
                leftConfig={leftConfig}
                visible={true}
                style={{"margin-top":"38px"}}
                onEmojiChange={emoji =>this.changeEmojField(emoji)}
                onImgChange={datas =>this.changeImgField(datas)}
                onBrowserChange={this.onBrownserchange}
                onUploadChange={(key, datas) => console.log('uploadChange', key, datas)}
            />}
          <div className={`${prefixCls}-container-position`}   onClick={this.getLocaiton}>
            <Icon type={address !== '' ? 'position' : 'location'} size='xxs'/>
            <span className={positionName} position={position}>{positionLoading ? getLabel(505617,'定位中...') : positionError ? getLabel(505618,'定位失败，请重试!') : positionStr}</span>
          </div>
            {this.state.bdShare=='0'&&shareType==1?"":<div className="blog-comment-write-container-position shareitem" onClick={this.openShareTool}><span
                className="blog-comment-write-container-position-name shareitemname" style={shareNameSt} >{shareName}</span>
                <Icon type='more-1' size='xxs' style={{"position": "absolute","bottom": "5px", "right":"8px"}}/>
            </div>}
        </div>
        {
             window.location.href.indexOf('/myBlog/blog/writeMyBlog')>0?"": (<Button
              onClick={this.saveNote}
              loading = {noteLoading}
              style = {{width:"50%"}}
              className='bottombtn'
              >{noteLoading ? getLabel(31116,'保存中'):getLabel(384355,'存草稿')}</Button>
             )
          }
          {
              window.location.href.indexOf('/myBlog/blog/writeMyBlog')>0? <Button type="primary"
                                                                                  className='bottombtn'
                                                                                  disabled={blogText ? false : true}
                                                                                  onClick={this.publishWeiboPermission}
                                                                                  loading = {loading}
              >{loading ? getLabel(513695,'发布中') :getLabel(114,'发布') }</Button>: (<Button type="primary"
                                                         disabled={ blogText ? false : true}
                                                         onClick={this.publishWeiboPermission}
                                                         loading = {loading}
                                                         className='bottombtn'
                                                         style = {{width:"50%","margin-left":" 50%",}}
                  >{loading ? getLabel(513695,'发布中') :getLabel(114,'发布') }</Button>
              )
          }

          <div className="blog-comment-write-container-position shareitem" onClick={() => {
              this.setState({  isButton: false });
              history.push(disscussShareLayout.path)
          }}><span
              className="blog-comment-write-container-position-name shareitemname" style={shareNameSt} >{shareName}</span>
              <Icon type='more-1' size='xxs' style={{"position": "absolute","bottom": "5px", "right":"8px"}}/>
          </div>

          <Route
              key={disscussShareLayout.id}
              path={disscussShareLayout.path}
              render={() => (
                  <RouteLayout>
                      <div
                          id='disshare'
                          key="wmPoutePageDemo"
                          className="wm-route-layout"
                      >
                      <DiscussShareTool shareType={shareType} changeShareUserList={this.changeShareUserList} shareUserList={shareUserList} discussid={discussId}  onCheckOk={this.onCheckOk} shareValue={shareValue}/>

                      </div>
                  </RouteLayout>
              )}
          />

          <Route
              key={disscussShareLayoutTwo.id}
              path={disscussShareLayoutTwo.path}
              render={() => (
                  <RouteLayout>
                      <div
                          id='dissharse'
                          key="wmPoutePageDemos"
                          className="wm-route-layout"
                      >
                          <DiscussShareTool shareType={shareType} shareUserList={shareUserList} changeShareUserList={this.changeShareUserList} shareType={shareType} discussid={discussId}  onCheckOk={this.onCheckOk} shareValue={shareValue}/>

                      </div>
                  </RouteLayout>
              )}
          />
      </div>
    );
  }
}